function loadJQuery(callback) {
	//create script element
	var script = document.createElement('script');
	script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js';
	
	// then bind the event to the callback function 
	script.onload = callback;
	
	// add script to the head
	var head = document.getElementsByTagName('head')[0];
	// fire the loading
	head.appendChild(script);
}

function styleCode() {			
	var shouldPrettyPrint = false;
	$('pre code').parent().each(function() {
		if (!$(this).hasClass('prettyprint')) {
			$(this).addClass('prettyprint');
			shouldPrettyPrint = true;
		}
	});	
	if (shouldPrettyPrint) { 
		prettyPrint();
	} 
}

function run() {
	loadJQuery((function() {
		//Load css
		jQuery('head').append(jQuery('<link/>').attr({
				'rel':'stylesheet',
				'type':'text/css',
				'href':'http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css'
				}));
				
		//Customize css
		jQuery('.prettyprint').css('overflow-x', 'scroll');
		
		//Style code
		jQuery.getScript("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js", function() {
			styleCode();
		});
	}));
}

run();